 <!DOCTYPE html>
 
<%@ page import="java.sql.*" %> 
<%@ page import="java.io.*" %> 
<%@ page import="java.util.Date" %> 
<%@ page import="java.text.DateFormat" %> 
<%@ page import="java.text.SimpleDateFormat" %> 


<% 
try {
	
	String connectionURL = "jdbc:mysql://localhost:3306/unilearn"; 
	
	int c_row_count = 0;
	Connection connection = null;
	Statement stmt = null;
	ResultSet rst=null;
	ResultSet rs = null;

	Class.forName("com.mysql.jdbc.Driver").newInstance(); 

	connection = DriverManager.getConnection(connectionURL, "root", "");
	stmt = connection.createStatement();
	Statement stmt1 = connection.createStatement();
	
	if(!connection.isClosed())
	{
		
		
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd");
		DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
		Date _now = new Date();
		
		String _assignment_sub_id = request.getParameter("assignmentSubID");
		String assign_name = request.getParameter("assignmentName");
		
		//get session values
		String user_id = (String)session.getAttribute("UserID");
		String permission = (String)session.getAttribute("Permission");
		String subject_code = (String)session.getAttribute("SubjectCode");
		String subject_name = (String)session.getAttribute("SubjectName");
		String st_user_id = (String)session.getAttribute("StudentUserID");
		
		
		
		String st_user_first_name = "";
		String st_user_last_name = "";
		String st_id_number = "";
		
		rs = stmt1.executeQuery("SELECT * FROM user WHERE user_id = '"+st_user_id+"' ");
		
		while(rs.next())
		{
			st_user_first_name = rs.getString("first_name");
			st_user_last_name = rs.getString("last_name");
			st_id_number = rs.getString("login_id");
		}
%>

<html lang="en">
<head>
<script type="text/javascript">

</script>
<link rel="stylesheet" type="text/css" href="common.css">
<title>UniLearn System</title>
</head>
<body>
<form action="tuAssignmentMark.jsp" method="post" name="entry" onSubmit="return validate(this)">
<table class="TblBody" style="width:720px">
	<tr>
		<td>
			<div class="contentb">
				<table width="100%">
                    <tr>
                        <td  style="background-color:#ccff99; font-size:20px; font-weight:bold; width:70%; height:30px">Detailed Mark Sheet</td>
						<!-- <td style="background-color:#ccff99; font-weight:bold;"><%= dateFormat2.format(_now) %>&nbsp;&nbsp; Time: <%= timeFormat.format(_now) %></td> -->
                    </tr>
					<tr>
                        <td colspan="2">
							<%
								int ttl_mark = 0;
								int ttl_max_mark = 0;
								String _result = "";
								_result += "Provisional Mark for: <br />" + 
											"Subject :" + subject_code + "-" + subject_name + "<br />" + 
											"Assignment : " + assign_name + "<br />" +
											"Student : " + st_user_first_name + st_user_last_name + "(" + st_id_number + ")" + "<br /><br />" +
											"Tutor marking details :  <br/>" + 
											"-----------------------------------------------------------------------------------------------------<br/>";
								
								rst = stmt.executeQuery("SELECT sm.assignment_mark_id, sm.mark, sms.scheme_desc, sms.maxScore " +
														"FROM assignment_mark sm, assignment_marking_scheme sms " +
														"WHERE sm.ass_mark_scheme_id = sms.ass_mark_scheme_id " + 
														"AND sm.assignment_sub_id = '"+_assignment_sub_id+"' ");
								
								while(rst.next())
								{
									int tmp_mark = Integer.parseInt(rst.getString("mark"));
									int tmp_max_mark = Integer.parseInt(rst.getString("maxScore"));
									
									 _result = _result + rst.getString("scheme_desc") + "   " + rst.getString("mark") + "/" + rst.getString("maxScore") + "<br />";
									 _result = _result + "-----------------------------------------------------------------------------------------------------<br/>";
									 
									 ttl_mark = ttl_mark + tmp_mark;
									 ttl_max_mark = ttl_max_mark + tmp_max_mark;
								}
								
								_result = _result + "Total " + ttl_mark + "/" + ttl_max_mark + "<br />" + 
								"-----------------------------------------------------------------------------------------------------<br/>" + 
								"Tutor Mark = " + ttl_mark + "/" + ttl_max_mark + "<br />" + 
								"----------------------------------------------------------<br/>" +
								"Overall Mark = " + ttl_mark + "/" + ttl_max_mark + "<br />" + 
								"Late Penalty = Not Applicable <br/>" + 
								"----------------------------------------------------------<br/>" +
								"Final Mark = " + ttl_mark + "/" + ttl_max_mark + "<br />" + 
								"----------------------------------------------------------<br/>";
								
								
								out.println(_result);
							%>
                        </td>
					</tr>
				</table>
			</div>
		</td>
	</tr>
</table>
</form>
<%
}
	}catch(Exception ex){

		out.println(ex);
	}
%>
</body>
</html>